/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DLL;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.util.ArrayList;
import java.util.Arrays;


public class PhanHoiGoiTinBroadCast {
    
    /*
    public static void main(String[] args) throws Exception {
        packets gt = new packets();
        //Thao tac ghi nhan goi tin
        byte[] buf = new byte[1024];
        DatagramPacket dgp = new DatagramPacket(buf, buf.length);
        DatagramSocket sk = new DatagramSocket(4200);
        // byte array dung de send goi tin phan hoi
        byte[] bufSe = new byte[1024];
        while (true) {
            sk.receive(dgp);
            byte[] reBuf = dgp.getData();
            byte a = reBuf[0];
            if((char)a == '1')
            {
                //Nhan dc goi tin check chuk
                //Xu ly check tren tap tin
                byte[] dataB = Arrays.copyOfRange(reBuf, 1, reBuf.length);
                //Ten tap tin can tim
                String dataReceive = new String(dataB);
                //
                //Neu khong co thì break
                //Gia su neu co
                String flag = "2";
                ArrayList<String> data = new ArrayList<String>();
                String tenFile1 = "PhimMa.1";
                String tenFile2 = "PhimMa.2";
                data.add(tenFile1);
                data.add(tenFile2);
                bufSe = gt.ResponNormal(flag, data);
            }
            if((char)a == '3')
            {
                //Nhan duoc goi tin yeu cai ket noi
                //Tien hanh goi goi tin trao doi
                
                
            }
            if((char)a == '4')
            {
                //Nhan duoc goi tin stop
                byte[] dataB = Arrays.copyOfRange(reBuf, 1, reBuf.length);
                //Ten file can dung
                String dataReceive = new String(dataB);
                //Tien hanh ngung
            }
            if((char)a == '5')
            {
                //Nhan duoc goi tin yeu cau wait
            }
			DatagramPacket out = new DatagramPacket(bufSe, bufSe.length, dgp.getAddress(), dgp.getPort());
            sk.send(out);
        }
    }
    */ 
}
